| 1 | /* $NetBSD: sendmail.c,v 1.2 2017/02/14 01:16:47 christos Exp $ */ |
| 2 | |
| 3 | /*++ |
| 4 | /* NAME |
| 5 | /* sendmail 1 |
| 6 | /* SUMMARY |
| 7 | /* Postfix to Sendmail compatibility interface |
| 8 | /* SYNOPSIS |
| 9 | /* \fBsendmail\fR [\fIoption ...\fR] [\fIrecipient ...\fR] |
| 10 | /* |
| 11 | /* \fBmailq\fR |
| 12 | /* \fBsendmail -bp\fR |
| 13 | /* |
| 14 | /* \fBnewaliases\fR |
| 15 | /* \fBsendmail -I\fR |
| 16 | /* DESCRIPTION |
| 17 | /* The Postfix \fBsendmail\fR(1) command implements the Postfix |
| 18 | /* to Sendmail compatibility interface. |
| 19 | /* For the sake of compatibility with existing applications, some |
| 20 | /* Sendmail command-line options are recognized but silently ignored. |
| 21 | /* |
| 22 | /* By default, Postfix \fBsendmail\fR(1) reads a message from |
| 23 | /* standard input |
| 24 | /* until EOF or until it reads a line with only a \fB.\fR character, |
| 25 | /* and arranges for delivery. Postfix \fBsendmail\fR(1) relies on the |
| 26 | /* \fBpostdrop\fR(1) command to create a queue file in the \fBmaildrop\fR |
| 27 | /* directory. |
| 28 | /* |
| 29 | /* Specific command aliases are provided for other common modes of |
| 30 | /* operation: |
| 31 | /* .IP \fBmailq\fR |
| 32 | /* List the mail queue. Each entry shows the queue file ID, message |
| 33 | /* size, arrival time, sender, and the recipients that still need to |
| 34 | /* be delivered. If mail could not be delivered upon the last attempt, |
| 35 | /* the reason for failure is shown. The queue ID string is |
| 36 | /* followed by an optional status character: |
| 37 | /* .RS |
| 38 | /* .IP \fB*\fR |
| 39 | /* The message is in the \fBactive\fR queue, i.e. the message is |
| 40 | /* selected for delivery. |
| 41 | /* .IP \fB!\fR |
| 42 | /* The message is in the \fBhold\fR queue, i.e. no further delivery |
| 43 | /* attempt will be made until the mail is taken off hold. |
| 44 | /* .RE |
| 45 | /* .IP |
| 46 | /* This mode of operation is implemented by executing the |
| 47 | /* \fBpostqueue\fR(1) command. |
| 48 | /* .IP \fBnewaliases\fR |
| 49 | /* Initialize the alias database. If no input file is specified (with |
| 50 | /* the \fB-oA\fR option, see below), the program processes the file(s) |
| 51 | /* specified with the \fBalias_database\fR configuration parameter. |
| 52 | /* If no alias database type is specified, the program uses the type |
| 53 | /* specified with the \fBdefault_database_type\fR configuration parameter. |
| 54 | /* This mode of operation is implemented by running the \fBpostalias\fR(1) |
| 55 | /* command. |
| 56 | /* .sp |
| 57 | /* Note: it may take a minute or so before an alias database update |
| 58 | /* becomes visible. Use the "\fBpostfix reload\fR" command to eliminate |
| 59 | /* this delay. |
| 60 | /* .PP |
| 61 | /* These and other features can be selected by specifying the |
| 62 | /* appropriate combination of command-line options. Some features are |
| 63 | /* controlled by parameters in the \fBmain.cf\fR configuration file. |
| 64 | /* |
| 65 | /* The following options are recognized: |
| 66 | /* .IP "\fB-Am\fR (ignored)" |
| 67 | /* .IP "\fB-Ac\fR (ignored)" |
| 68 | /* Postfix sendmail uses the same configuration file regardless of |
| 69 | /* whether or not a message is an initial submission. |
| 70 | /* .IP "\fB-B \fIbody_type\fR" |
| 71 | /* The message body MIME type: \fB7BIT\fR or \fB8BITMIME\fR. |
| 72 | /* .IP \fB-bd\fR |
| 73 | /* Go into daemon mode. This mode of operation is implemented by |
| 74 | /* executing the "\fBpostfix start\fR" command. |
| 75 | /* .IP "\fB-bh\fR (ignored)" |
| 76 | /* .IP "\fB-bH\fR (ignored)" |
| 77 | /* Postfix has no persistent host status database. |
| 78 | /* .IP \fB-bi\fR |
| 79 | /* Initialize alias database. See the \fBnewaliases\fR |
| 80 | /* command above. |
| 81 | /* .IP \fB-bl\fR |
| 82 | /* Go into daemon mode. To accept only local connections as |
| 83 | /* with Sendmail\'s \fB-bl\fR option, specify "\fBinet_interfaces |
| 84 | /* = loopback\fR" in the Postfix \fBmain.cf\fR configuration |
| 85 | /* file. |
| 86 | /* .IP \fB-bm\fR |
| 87 | /* Read mail from standard input and arrange for delivery. |
| 88 | /* This is the default mode of operation. |
| 89 | /* .IP \fB-bp\fR |
| 90 | /* List the mail queue. See the \fBmailq\fR command above. |
| 91 | /* .IP \fB-bs\fR |
| 92 | /* Stand-alone SMTP server mode. Read SMTP commands from |
| 93 | /* standard input, and write responses to standard output. |
| 94 | /* In stand-alone SMTP server mode, mail relaying and other |
| 95 | /* access controls are disabled by default. To enable them, |
| 96 | /* run the process as the \fBmail_owner\fR user. |
| 97 | /* .sp |
| 98 | /* This mode of operation is implemented by running the |
| 99 | /* \fBsmtpd\fR(8) daemon. |
| 100 | /* .IP \fB-bv\fR |
| 101 | /* Do not collect or deliver a message. Instead, send an email |
| 102 | /* report after verifying each recipient address. This is useful |
| 103 | /* for testing address rewriting and routing configurations. |
| 104 | /* .sp |
| 105 | /* This feature is available in Postfix version 2.1 and later. |
| 106 | /* .IP "\fB-C \fIconfig_file\fR" |
| 107 | /* .IP "\fB-C \fIconfig_dir\fR" |
| 108 | /* The path name of the Postfix \fBmain.cf\fR file, or of its |
| 109 | /* parent directory. This information is ignored with Postfix |
| 110 | /* versions before 2.3. |
| 111 | /* |
| 112 | /* With all Postfix versions, you can specify a directory pathname |
| 113 | /* with the MAIL_CONFIG environment variable to override the |
| 114 | /* location of configuration files. |
| 115 | /* .IP "\fB-F \fIfull_name\fR" |
| 116 | /* Set the sender full name. This overrides the NAME environment |
| 117 | /* variable, and is used only with messages that |
| 118 | /* have no \fBFrom:\fR message header. |
| 119 | /* .IP "\fB-f \fIsender\fR" |
| 120 | /* Set the envelope sender address. This is the address where |
| 121 | /* delivery problems are sent to. With Postfix versions before 2.1, the |
| 122 | /* \fBErrors-To:\fR message header overrides the error return address. |
| 123 | /* .IP \fB-G\fR |
| 124 | /* Gateway (relay) submission, as opposed to initial user |
| 125 | /* submission. Either do not rewrite addresses at all, or |
| 126 | /* update incomplete addresses with the domain information |
| 127 | /* specified with \fBremote_header_rewrite_domain\fR. |
| 128 | /* |
| 129 | /* This option is ignored before Postfix version 2.3. |
| 130 | /* .IP "\fB-h \fIhop_count\fR (ignored)" |
| 131 | /* Hop count limit. Use the \fBhopcount_limit\fR configuration |
| 132 | /* parameter instead. |
| 133 | /* .IP \fB-I\fR |
| 134 | /* Initialize alias database. See the \fBnewaliases\fR |
| 135 | /* command above. |
| 136 | /* .IP "\fB-i\fR" |
| 137 | /* When reading a message from standard input, don\'t treat a line |
| 138 | /* with only a \fB.\fR character as the end of input. |
| 139 | /* .IP "\fB-L \fIlabel\fR (ignored)" |
| 140 | /* The logging label. Use the \fBsyslog_name\fR configuration |
| 141 | /* parameter instead. |
| 142 | /* .IP "\fB-m\fR (ignored)" |
| 143 | /* Backwards compatibility. |
| 144 | /* .IP "\fB-N \fIdsn\fR (default: 'delay, failure')" |
| 145 | /* Delivery status notification control. Specify either a |
| 146 | /* comma-separated list with one or more of \fBfailure\fR (send |
| 147 | /* notification when delivery fails), \fBdelay\fR (send |
| 148 | /* notification when delivery is delayed), or \fBsuccess\fR |
| 149 | /* (send notification when the message is delivered); or specify |
| 150 | /* \fBnever\fR (don't send any notifications at all). |
| 151 | /* |
| 152 | /* This feature is available in Postfix 2.3 and later. |
| 153 | /* .IP "\fB-n\fR (ignored)" |
| 154 | /* Backwards compatibility. |
| 155 | /* .IP "\fB-oA\fIalias_database\fR" |
| 156 | /* Non-default alias database. Specify \fIpathname\fR or |
| 157 | /* \fItype\fR:\fIpathname\fR. See \fBpostalias\fR(1) for |
| 158 | /* details. |
| 159 | /* .IP "\fB-O \fIoption=value\fR (ignored)" |
| 160 | /* Set the named \fIoption\fR to \fIvalue\fR. Use the equivalent |
| 161 | /* configuration parameter in \fBmain.cf\fR instead. |
| 162 | /* .IP "\fB-o7\fR (ignored)" |
| 163 | /* .IP "\fB-o8\fR (ignored)" |
| 164 | /* To send 8-bit or binary content, use an appropriate MIME encapsulation |
| 165 | /* and specify the appropriate \fB-B\fR command-line option. |
| 166 | /* .IP "\fB-oi\fR" |
| 167 | /* When reading a message from standard input, don\'t treat a line |
| 168 | /* with only a \fB.\fR character as the end of input. |
| 169 | /* .IP "\fB-om\fR (ignored)" |
| 170 | /* The sender is never eliminated from alias etc. expansions. |
| 171 | /* .IP "\fB-o \fIx value\fR (ignored)" |
| 172 | /* Set option \fIx\fR to \fIvalue\fR. Use the equivalent |
| 173 | /* configuration parameter in \fBmain.cf\fR instead. |
| 174 | /* .IP "\fB-r \fIsender\fR" |
| 175 | /* Set the envelope sender address. This is the address where |
| 176 | /* delivery problems are sent to. With Postfix versions before 2.1, the |
| 177 | /* \fBErrors-To:\fR message header overrides the error return address. |
| 178 | /* .IP "\fB-R \fIreturn\fR" |
| 179 | /* Delivery status notification control. Specify "hdrs" to |
| 180 | /* return only the header when a message bounces, "full" to |
| 181 | /* return a full copy (the default behavior). |
| 182 | /* |
| 183 | /* The \fB-R\fR option specifies an upper bound; Postfix will |
| 184 | /* return only the header, when a full copy would exceed the |
| 185 | /* bounce_size_limit setting. |
| 186 | /* |
| 187 | /* This option is ignored before Postfix version 2.10. |
| 188 | /* .IP \fB-q\fR |
| 189 | /* Attempt to deliver all queued mail. This is implemented by |
| 190 | /* executing the \fBpostqueue\fR(1) command. |
| 191 | /* |
| 192 | /* Warning: flushing undeliverable mail frequently will result in |
| 193 | /* poor delivery performance of all other mail. |
| 194 | /* .IP "\fB-q\fIinterval\fR (ignored)" |
| 195 | /* The interval between queue runs. Use the \fBqueue_run_delay\fR |
| 196 | /* configuration parameter instead. |
| 197 | /* .IP \fB-qI\fIqueueid\fR |
| 198 | /* Schedule immediate delivery of mail with the specified queue |
| 199 | /* ID. This option is implemented by executing the |
| 200 | /* \fBpostqueue\fR(1) command, and is available with Postfix |
| 201 | /* version 2.4 and later. |
| 202 | /* .IP \fB-qR\fIsite\fR |
| 203 | /* Schedule immediate delivery of all mail that is queued for the named |
| 204 | /* \fIsite\fR. This option accepts only \fIsite\fR names that are |
| 205 | /* eligible for the "fast flush" service, and is implemented by |
| 206 | /* executing the \fBpostqueue\fR(1) command. |
| 207 | /* See \fBflush\fR(8) for more information about the "fast flush" |
| 208 | /* service. |
| 209 | /* .IP \fB-qS\fIsite\fR |
| 210 | /* This command is not implemented. Use the slower "\fBsendmail -q\fR" |
| 211 | /* command instead. |
| 212 | /* .IP \fB-t\fR |
| 213 | /* Extract recipients from message headers. These are added to any |
| 214 | /* recipients specified on the command line. |
| 215 | /* |
| 216 | /* With Postfix versions prior to 2.1, this option requires that |
| 217 | /* no recipient addresses are specified on the command line. |
| 218 | /* .IP "\fB-U\fR (ignored)" |
| 219 | /* Initial user submission. |
| 220 | /* .IP "\fB-V \fIenvid\fR" |
| 221 | /* Specify the envelope ID for notification by servers that |
| 222 | /* support DSN. |
| 223 | /* |
| 224 | /* This feature is available in Postfix 2.3 and later. |
| 225 | /* .IP "\fB-XV\fR (Postfix 2.2 and earlier: \fB-V\fR)" |
| 226 | /* Variable Envelope Return Path. Given an envelope sender address |
| 227 | /* of the form \fIowner-listname\fR@\fIorigin\fR, each recipient |
| 228 | /* \fIuser\fR@\fIdomain\fR receives mail with a personalized envelope |
| 229 | /* sender address. |
| 230 | /* .sp |
| 231 | /* By default, the personalized envelope sender address is |
| 232 | /* \fIowner-listname\fB+\fIuser\fB=\fIdomain\fR@\fIorigin\fR. The default |
| 233 | /* \fB+\fR and \fB=\fR characters are configurable with the |
| 234 | /* \fBdefault_verp_delimiters\fR configuration parameter. |
| 235 | /* .IP "\fB-XV\fIxy\fR (Postfix 2.2 and earlier: \fB-V\fIxy\fR)" |
| 236 | /* As \fB-XV\fR, but uses \fIx\fR and \fIy\fR as the VERP delimiter |
| 237 | /* characters, instead of the characters specified with the |
| 238 | /* \fBdefault_verp_delimiters\fR configuration parameter. |
| 239 | /* .IP \fB-v\fR |
| 240 | /* Send an email report of the first delivery attempt (Postfix |
| 241 | /* versions 2.1 and later). Mail delivery |
| 242 | /* always happens in the background. When multiple \fB-v\fR |
| 243 | /* options are given, enable verbose logging for debugging purposes. |
| 244 | /* .IP "\fB-X \fIlog_file\fR (ignored)" |
| 245 | /* Log mailer traffic. Use the \fBdebug_peer_list\fR and |
| 246 | /* \fBdebug_peer_level\fR configuration parameters instead. |
| 247 | /* SECURITY |
| 248 | /* .ad |
| 249 | /* .fi |
| 250 | /* By design, this program is not set-user (or group) id. However, |
| 251 | /* it must handle data from untrusted, possibly remote, users. |
| 252 | /* Thus, the usual precautions need to be taken against malicious |
| 253 | /* inputs. |
| 254 | |
|---|